<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>库存管理 - 疫苗预约系统</title>
    <link rel="stylesheet" href="../css/common.css?v=20251119">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
</head>
<body>
    <div class="main-container">
        <!-- 侧边栏 -->
        <div class="sidebar">
            <div class="sidebar-header">
                <i class="fas fa-syringe"></i>
                <h2>疫苗预约系统</h2>
                <p>接种点管理员</p>
            </div>
            <nav class="sidebar-menu">
                <a href="home.html" class="menu-item">
                    <i class="fas fa-home"></i>
                    <span>首页</span>
                </a>
                <a href="inventory.html" class="menu-item active">
                    <i class="fas fa-boxes"></i>
                    <span>库存管理</span>
                </a>
                <a href="appointment.html" class="menu-item">
                    <i class="fas fa-calendar-check"></i>
                    <span>预约管理</span>
                </a>
                <a href="statistics.html" class="menu-item">
                    <i class="fas fa-chart-bar"></i>
                    <span>数据统计</span>
                </a>
            </nav>
        </div>

        <!-- 主内容区域 -->
        <div class="main-content" id="mainContent">
            <!-- 低库存预警提示条 -->
            <div class="low-stock-alert-bar" id="lowStockAlertBar">
                <div class="low-stock-alert-content">
                    <i class="fas fa-exclamation-triangle low-stock-alert-icon"></i>
                    <span class="low-stock-alert-text" id="lowStockAlertText">检测到低库存预警，请及时补充库存</span>
                </div>
                <button class="low-stock-alert-close" onclick="closeLowStockAlert()">
                    <i class="fas fa-times"></i>
                </button>
            </div>
            
            <!-- 顶部导航栏 -->
            <div class="top-navbar">
                <div class="navbar-left">
                    <h1>库存管理</h1>
                </div>
                <div class="navbar-right">
                    <div class="user-info">
                        <div class="user-avatar" id="userAvatar">A</div>
                        <span class="user-name" id="userName">管理员</span>
                    </div>
                    <button class="btn-logout" onclick="handleLogout()">
                        <i class="fas fa-sign-out-alt"></i> 退出登录
                    </button>
                </div>
            </div>

            <!-- 内容区域 -->
            <div class="content-area">
                <!-- 页面标题 -->
                <div class="page-header">
                    <h2 class="page-title">库存管理</h2>
                    <p class="page-subtitle">管理疫苗库存信息</p>
                </div>

                <!-- 操作按钮 -->
                <div class="card">
                    <div class="card-body">
                        <div style="display: flex; gap: 10px;">
                            <button class="btn btn-primary" onclick="showAddInventoryModal()">
                                <i class="fas fa-plus"></i> 添加库存
                            </button>
                            <button class="btn btn-warning" onclick="loadLowStockAlerts()">
                                <i class="fas fa-exclamation-triangle"></i> 查看低库存预警
                            </button>
                            <button class="btn btn-secondary" onclick="loadInventoryList()">
                                <i class="fas fa-sync"></i> 刷新列表
                            </button>
                        </div>
                    </div>
                </div>

                <!-- 库存列表 -->
                <div class="card">
                    <div class="card-header">
                        <h3 class="card-title" id="listTitle">库存列表</h3>
                    </div>
                    <div class="card-body">
                        <div class="table-container">
                            <table>
                                <thead>
                                    <tr>
                                        <th>疫苗名称</th>
                                        <th>疫苗类型</th>
                                        <th>当前库存</th>
                                        <th>预警阈值</th>
                                        <th>生产日期</th>
                                        <th>过期日期</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody id="inventoryTableBody">
                                    <tr>
                                        <td colspan="7" style="text-align: center; padding: 40px; color: #999;">
                                            <i class="fas fa-spinner fa-spin" style="font-size: 48px; margin-bottom: 10px; display: block;"></i>
                                            加载中...
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- 添加库存模态框 -->
    <div id="addInventoryModal" class="modal">
        <div class="modal-content">
            <div class="modal-header">
                <h3>添加库存</h3>
                <span class="close" onclick="closeAddInventoryModal()">&times;</span>
            </div>
            <div class="modal-body">
                <form id="addInventoryForm">
                    <div class="form-group">
                        <label>疫苗 <span style="color: red;">*</span></label>
                        <select id="vaccineId" required>
                            <option value="">请选择疫苗</option>
                        </select>
                    </div>
                    <div class="form-group">
                        <label>库存数量 <span style="color: red;">*</span></label>
                        <input type="number" id="quantity" placeholder="请输入库存数量" min="1" required>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button class="btn btn-secondary" onclick="closeAddInventoryModal()">取消</button>
                <button class="btn btn-primary" onclick="handleAddInventory()">确定</button>
            </div>
        </div>
    </div>

    <!-- 更新库存模态框 -->
    <div id="updateInventoryModal" class="modal">
        <div class="modal-content">
            <div class="modal-header">
                <h3>更新库存数量</h3>
                <span class="close" onclick="closeUpdateInventoryModal()">&times;</span>
            </div>
            <div class="modal-body">
                <form id="updateInventoryForm">
                    <input type="hidden" id="updateInventoryId">
                    <div class="form-group">
                        <label>疫苗名称</label>
                        <input type="text" id="updateVaccineName" readonly style="background: #f5f5f5;">
                    </div>
                    <div class="form-group">
                        <label>当前库存</label>
                        <input type="text" id="updateCurrentQuantity" readonly style="background: #f5f5f5;">
                    </div>
                    <div class="form-group">
                        <label>新库存数量 <span style="color: red;">*</span></label>
                        <input type="number" id="updateQuantity" placeholder="请输入新的库存数量" min="0" required>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button class="btn btn-secondary" onclick="closeUpdateInventoryModal()">取消</button>
                <button class="btn btn-primary" onclick="handleUpdateInventory()">确定</button>
            </div>
        </div>
    </div>

    <script src="../js/common.js?v=20251120_9"></script>
    <script src="js/inventory.js?v=20251120_9"></script>
</body>
</html>

